///************************************************************************
/// <copyrigth>2018-2019 Corporation.All Rights Reserved</copyrigth>
/// <author>tangyingzhong</author>
/// <contact>tangyz114987@outlook.com</contact>
/// <version>v1.0.0</version>
/// <describe>
/// Offering common interface for all plugins
///</describe>
/// <date>2019/7/25</date>
///***********************************************************************
#ifndef IPLUGIN_H
#define IPLUGIN_H

#include "Tool/EventHandler/IEventHandler.h"

#define PLUGIN_DIRECTORY "Plugin"

class IPlugin
{
public:
	typedef IEventHandler::HandlerFunc HandlerFunc;

public:
	// Virtual detructe the plugin
	virtual ~IPlugin() {	}

public:
	// Start the plugin
	virtual bool Start() = 0;

	// Stop the plugin
	virtual bool Stop() = 0;

	// Is plugin running
	virtual bool IsRunning() = 0;

	// Is main service
	virtual bool IsMainService() = 0;

	// Is started on load
	virtual bool IsStartOnLoad() = 0;

	// Set plugin name
	virtual bool SetName(std::string strName) = 0;

	// Get plugin name
	virtual std::string GetName() = 0;

	// Set plugin version
	virtual bool SetVersion(int iMajorVersion,
		int iMinorVersion,
		int iModifyVersion) = 0;

	// Get plugin version
	virtual bool GetVersion(int& iMajorVersion,
		int& iMinorVersion,
		int& iModifyVersion) = 0;

	// Check plugin's compatility
	virtual bool CheckCompatible(int iMajorVersion,
		int iMinorVersion,
		int iModifyVersion) = 0;

	// Listen plugins
	virtual void Listen(void* pListener,
		HandlerFunc pListenHandler,
		int iEventID) = 0;
};

#endif //IPLUGIN_H
